package com.socialbank.web.controller;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.socialbank.web.util.HttpUtils;
import com.socialbank.web.util.SocialBankUtils;

/**   
 * 
 * @Package: com.socialbank.web.controller 
 * @author: kangxiaohui   
 * @date: 2017年8月30日 上午9:41:10 
 * 社交银行的商品模块
 */
@Controller
@RequestMapping("sys/goods")
public class GoodsController {

	/**
	 * 查询全部商品
	 * @param request
	 * @param map
	 * @return
	 */
	@RequestMapping("/all")
	public @ResponseBody Object getGoodsList(HttpServletRequest request, @RequestBody Map<String, Object> map){
		String result = HttpUtils.postWithJSON(map, SocialBankUtils.GOODS_ALL);
		if(StringUtils.isNoneBlank(result)){
			return result;
		}else{
			return new HashMap<>();
		}
	}
	
	/**
	 * 批量审批商品
	 * @param request
	 * @param map
	 */
	@RequestMapping(value = "/check")
	public @ResponseBody Object check(HttpServletRequest request, @RequestBody Map<String, Object> map){
		String result = HttpUtils.postWithJSON(map, SocialBankUtils.GOODS_CHECK);
		if(StringUtils.isNoneBlank(result)){
			return result;
		}else{
			return new HashMap<>();
		}
	}
	
	/**
	 * 商品详情
	 * @return
	 */
	@RequestMapping("/toGoodsDetail")
	public String toBusinessDetail(){
		return "businessManager/detailGoods";
	}
	
	/**
	 * 商家详情
	 * @param request
	 * @param requestParamJson
	 * @return
	 */
	@RequestMapping(value = "/detail/{id}")
	public @ResponseBody Object check(HttpServletRequest request, @PathVariable Long id){
		String result = HttpUtils.get(new HashMap<String,Object>(), SocialBankUtils.GOODS_DETAIL + "/" + id);
		if(StringUtils.isNoneBlank(result)){
			return result;
		}else{
			return new HashMap<>();
		}
	}
	
	/**
	 * 商家列表
	 * @return
	 */
	@RequestMapping("/toReviewGoods")
	public String toReviewBusiness(){
		return "businessManager/reviewGoods";
	}
	
	/**
	 * 销量统计
	 * @return
	 */
	@RequestMapping("/toStatisticsGoods")
	public String toStatisticsGoods(){
		return "businessManager/statisticsGoods";
	}
	
	/**
	 * 商品销量
	 */
	@RequestMapping(value = "/sales")
	public @ResponseBody Object getSalesGoodsInfo(HttpServletRequest request,  @RequestBody Map<String, Object> map){
		String result = HttpUtils.postWithJSON(map, SocialBankUtils.GOODS_SALES);
		if(StringUtils.isNoneBlank(result)){
			return result;
		}else{
			return new HashMap<>();
		}
	}
	
	/**
	 * 商家销售额统计
	 */
	@RequestMapping(value = "/business/sales")
	public @ResponseBody Object getBusinessSales(HttpServletRequest request,  @RequestBody Map<String, Object> map){
		String result = HttpUtils.postWithJSON(map, SocialBankUtils.GOODS_BUSINESS_SALES);
		if(StringUtils.isNoneBlank(result)){
			return result;
		}else{
			return new HashMap<>();
		}
	}
	
	
}
